package com.realgodo.site.web.user.communication;

import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;

import com.opensymphony.xwork2.Action;
import com.realgodo.site.entity.application.Application;
import com.realgodo.site.entity.application.communication.Commentary;

@Scope("prototype")
@Result(name = Action.SUCCESS, type = "redirect", location = "${base}/user/communication/?id=${application.id}&moddle=${moddle}")
public class CommentController extends IndexController{

	/***/
	private static final long serialVersionUID = 447415020735047829L;
	
	/**评论实体*/
	private Commentary commentary;
	
	/**发表评论*/
	@Override
	public String execute() throws Exception {
		return save();
	}

	/**保存评论*/
	public String save(){
		if(commentary.getApplication()==null){
			application=new Application();
			application.setId(id);
			commentary.setApplication(application);
		}
		commentary.setPublisher(super.getSpace());
		commentary=commentaryManager.saveCommentary(commentary);
		application=commentary.getApplication();
		return SUCCESS;
	}
	

	//------------------get/set---------//
	
	
	public Commentary getCommentary() {
		return commentary;
	}

	public void setCommentary(Commentary commentary) {
		this.commentary = commentary;
	}
	
	
}
